import { formDate,setSStore,Trim } from "@/utils/util"
import Load from '@/components/Load.vue'
export default {
	data() {
		return {
			loading:false,
			data:[],
			query:{
				orderId:"",
				beginDate:"",
				endDate:"",
				pageNum:1,
				pageSize:5,
				status:null,
			},
			status:[
				{name:'全部',key:null},
				{name:'待支付',key:"PAYING"},
				{name:'已完成',key:"SUCCESS"},
				{name:'已取消',key:"CANCEL"},
			],
			active:null,
			total:null,
		}
	},
	computed: {
		
	},
	watch:{
		
	},
	methods: {
		search(){
			this.query.Status = null;
			this.active = null;
			this.getData();
		},
		getData(){			
	        this.query.orderId = Trim(this.query.orderId);	        	        
	        this.query.beginDate = formDate(this.query.beginDate);	        	        
	        this.query.endDate = formDate(this.query.endDate);	        	        
			this.loading = true;
			this.$http.post('/train/orderList',this.query)
				.then((res) => {
					this.loading = false;
					let status = res.data.status;
					if(status==1001){
						this.data = res.data.data.list;
						this.total = res.data.data.total;
						if(this.total==0){
							this.$message('搜索结果为空');
							return;
						}
						return;
					}
					this.$notify.error({
			          title: '请求失败',
			          message: '请检查网络连接或者更换搜索条件',
			          duration: 3000
			        });
				})
		},
		//选择不同状态的订单数据
		chooseStatus(status){	
			this.active = status;
			this.query.Status = status;
			this.getData();			
		},
		//分页
		pageChange(val){
			this.query.pageNum = val;
			this.getData();
		},
		detail(orderId){
			window.open(`#/orderManage/train/detail?orderId=${orderId}`)
		}
	},
	components:{
		Load,
	},
	created() {
		this.getData();
	}
}